{% extends  'base.html' %}
        
{% block content %}

	{% ifequal action "edit" %}
		<h1>{{uidp.name}}</h1>
	{% else %}
		<h1>Novo UIDP</h1>
	{% endifequal %}
	
	<p>Insira abaixo as informações sobre o novo padrão de interface com o usuário.</p>
	
	<form action="" method="post" id="uidp_form" class='form'>
		<table>
			{{ form.as_table }}
		</table>
		<script>
			$("#id_name").attr("value", "{{ uidp.name }}");
			$("#id_problem").attr("value", "{{ uidp.problem }}");
			$("#id_context").attr("value", "{{ uidp.context }}");
		</script>

		<div class="label">Categorias:</div>
		<div>
			
		{% for c in categories %}
			<td>
				{% if c in selected_categories %}
					<input type="checkbox" name="category" value={{c.id}} id={{c.id}} checked />{{ c.name }}
				{% else %}
					<input type="checkbox" name="category" value={{c.id}} id={{c.id}} />{{ c.name }}
				{% endif %}
			</td>
			
			{% if forloop.counter|divisibleby:"3" %}
				</div><div>
			{% endif %}
			
		{% endfor %}
		
		<div class="clearfloat"></div>
				
		{% ifequal action "edit" %}
			<script>
				$("#id_name").hide();
				$("#id_name").parent().parent().hide();
			</script>
			<input type="button" value="Editar" class="button" id="new_uidp_button"/>
		{% else %}
			<input type="button" value="Adicionar" class="button" id="new_uidp_button"/>
		{% endifequal %}
		<a href="/collections/{{collection.id}}/uidps/{{uidp.id}}" ><input type="button" value="Cancelar" class="button" id="cancel_button"/></a>
		
	</form>

{% endblock %}